package org.example.classloader;

import java.util.Scanner;

/**
 * @author xuan
 * @create 2023/10/8
 */
public class ScannerTest {
    static Object A = new Object();
    static Object B = new Object();

    public static void main(String[] args) {
        Runnable task = new Runnable() {
            @Override
            public void run() {
                synchronized (A) {
                    try {
                        Thread.sleep(1000);
                        synchronized (B) {
                            System.out.println();
                        }
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        };
        Thread thread = new Thread(task);
        thread.start();

        synchronized (B) {
            try {
                Thread.sleep(1000);
                synchronized (A) {
                    System.out.println();
                }
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }

    }
}

